<div class="layui-fluid layui-anim febs-anim" id="businesses-college" lay-title="院校信息">
    <div class="layui-row febs-container">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body febs-table-full">
                    <form class="layui-form layui-table-form" lay-filter="college-table-form">
                        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                            <legend style="font-size: 15px; font-weight: bolder;">精确查询</legend>
                        </fieldset>
                        <div class="layui-row">
                            <div class="layui-col-md10">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">姓名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="stuName" autocomplete="off" class="layui-input" maxlength="10">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">组名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="groupNo" autocomplete="off" class="layui-input"  maxlength="10">
                                        </div>
                                    </div>

                                </div>
                            </div>
                            <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area">
                                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query">
                                    <i class="layui-icon">&#xe848;</i>
                                </div>
                                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset">
                                    <i class="layui-icon">&#xe79b;</i>
                                </div>
                                <!--                                <div class="layui-btn layui-btn-sm layui-btn-primary table-action action-more">-->
                                <!--                                    <i class="layui-icon">&#xe875;</i>-->
                                <!--                                </div>-->
                            </div>
                        </div>

                    </form>
                    <table lay-filter="userTaskTable" lay-data="{id: 'userTaskTable'}"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="xcollege-option">
    <a lay-event="edit" title="处理待办">
        <i class="layui-icon febs-edit-aread febs-blue">&#xe7a4;</i></a>
</script>
<script data-th-inline="none" type="text/javascript">
    layui.use(['dropdown', 'jquery', 'form', 'table', 'febs'], function () {
        let $ = layui.jquery,
            febs = layui.febs,
            form = layui.form,
            table = layui.table,
            dropdown = layui.dropdown,
            $view = $('#businesses-college'),
            $query = $view.find('#query'),
            $add = $view.find('#add'),
            $export = $view.find('#export'),
            $reset = $view.find('#reset'),
            $searchForm = $view.find('form'),
            sortObject = {field: 'createDate', type: null},
            tableIns;

        form.render();

        initTable();

        // which属性判断按下的是哪个键，回车键的键位序号为13
        // 当按下按键时
        $(".layui-input").keydown(function (e) {
            if (e.which == 13) {
                $query.click();
                return;
            }
        });

        table.on('tool(userTaskTable)', function (obj) {
            let data = obj.data,
                layEvent = obj.event;

            if (layEvent === 'edit') {
                febs.modal.view('待办任务项', 'student/taskDetail/' + data.stuId, {
                    area: ['70%', '80%'],
                    tipsMore: true
                });
            }
        });

        table.on('sort(collegeTable)', function (obj) {
            sortObject = obj;
            tableIns.reload({
                initSort: obj,
                where: $.extend(getQueryParams(), {
                    field: obj.field,
                    order: obj.type
                })
            });
        });

        $query.on('click', function () {
            let params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type});
            tableIns.reload({where: params, page: {curr: 1}});
        });




        $reset.on('click', function () {
            $searchForm[0].reset();
            sortObject.type = 'null';
            tableIns.reload({where: getQueryParams(true), page: {curr: 1}, initSort: sortObject});
        });

        function initTable() {
            tableIns = febs.table.init({
                elem: $view.find('table'),
                id: 'userTaskTable',
                url:  'student/userTaskList?userId='+$("#userId").val(),
                cols: [[
                    {type: 'checkbox'},
                    {field: 'stuId',        title: '学生序号',        minWidth: 80},
                    {field: 'stuName',      title: '姓名',            minWidth: 80},
                    {field: 'groupNo',      title: '组名',          minWidth: 80},
                    {field: 'taskNum',      title: '待办数',          minWidth: 80},
                    {title: '操作', toolbar: '#xcollege-option', minWidth: 140},
                ]],

            });
        }

        function getQueryParams(flag) {
            let params = $searchForm.serializeJson();
            console.log(params)
            return params;
        }

    })
</script>